<%@ page language="java" pageEncoding="UTF-8"
	contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>嘉华留学网注册</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" type="text/css" href="resource/css/common.css">
		<style type="text/css">
		select{
			font-family: arial;
			font-size: 12px;
		}
		body{
			font-family: arial;
			font-size: 12px;
			background-color: #F9F8E8;
		}
		a{
			font-size: 12px;
			font-family: arial;
			font-weight: bold;
			color: green;
			text-decoration: none;
		}
		a:HOVER {
			color: red;
		}
		h4 {
			font-family: "宋体";	
			color: #006699;
		}
		table{
			font-size: 12px;
			font-family: arial;
			color: #234345;
		}
		input {
		    font-size: 9pt;
		    font-family: simsun;
		    border-top: 1px solid #5E5E5E;
		    border-right: 1px solid #C9C9C9;
		    border-bottom: 1px solid #C9C9C9;
		    border-left: 1px solid #5E5E5E;
		}
		.div_copyright{
			top:533px;
			left: 410px;
			position: absolute;
			font-size: 11px;
			font-weight:normal;
			font-family:arial;
			color: #808080;
		}
		.text{
			font-size: 9px;
		}
	</style>

	</head>
	<script language="JavaScript" src="resource/js/net.js"></script>
	<script type="text/javascript" src="resource/js/util.js"></script>
	<script language="JavaScript" src="resource/js/Calendar30.js"></script>
	<script language="javaScript">
	    WebCalendar.yearFall   = 100;           //定义年下拉框的年差值
	    WebCalendar.format     = "yyyy-mm-dd"; //回传日期的格式
  </script>

	<script language="javaScript" type="text/javascript"> 
	
	  
	  function myValidator(){
	  	var namev = document.myform.nickname.value;
	  	namev = namev.trim();
	  	document.myform.nickname.value = namev;
	  	if(namev == ""){
	  		var msgs = document.getElementById("msg_prompt");
	  		msgs.innerText = "用户名不能为空";
	  		return;
	  	}
	  	document.myform.action.value="myValidator";
  	    document.myform.submit();
	  }
	  
	  function validata(rand){
	  	 //验证码
	     var number=document.myform.number.value;
		 if(number.trim().length<1){
			alert("验证码需要填写");
			return;
		 }
		 if(rand != number){
			alert("验证码输入错误");
			return;
		 }
		 
		 //用户名  	
  		if(document.myform.nickname.value.trim().length<1){
 			alert("用户名不能为空");
  			return;
		}
		//密码
		if(document.myform.password.value.trim().length<6){
		 	alert("用户密码不能少于6位");
			return;
		}
		if(document.myform.password.value != document.myform.password2.value){
		 	alert("两次密码输入不同");
		 	return;
		}
		//密码提示问题
		var pqav = document.myform.passQuestionAnswer.value;
	    pqav = pqav.trim();
	    document.myform.passQuestionAnswer.value = pqav;
	    if(pqav.length < 2){
	   	  alert("密码提示问题请设置成2个字符以上。");
	   	  return;
	    }
		//email
		var email=document.myform.email.value;
		if(email == null || email.length<1){
		  	alert("email不能为空");  	
		  	return;
		}
		if(!/(\S)+[@]{1}(\S)+[.]{1}(\w)+/.test(email)){
			alert("email格式不正确");  	
	  		return;
	  	}
	  	//tel
	  	/*
	  	var tel=document.myform.tel.value.trim();
	  	//if(tel.length<1){
	  	//	alert("联系电话需要填写");
	  	//	return;
	  	}*/
	  	var tel=document.myform.tel.value.trim();
	  	if(tel > 0){
		  	var re=/(^[0-9]{3,4}\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\([0-9]{3,4}\)[0-9]{3,8}$)|(^0{0,1}1[0-9]{10}$)/;
		  	if(!re.test(tel)){
		  		alert("联系电话格式不正确");
		  		return;
		  	}
	  	}
	  	//address
	  	/*
	  	var address=document.myform.address.value.trim();
	  	if(address==null || address.length<1){
	  		alert("联系地址格式不正确");
	  		return;
	  	}*/
		document.myform.submit(); 
	  }
  
  </script>
	<body>
	<TABLE cellSpacing=0 cellPadding=0 border=0>
			<tr>
				<td class="cate_navi_td" width="718" height="27">
					<span style="font-weight: bold;padding-left: 6px;">新用户注册</span>
					<span style="padding-left: 540px"><a href="javascript:window.close()">CLOSE</a></span>
				</td>
			</tr>
			<tr>
			    <td><p>&nbsp;</p></td>
			</tr>
			<tr>
				<td width="718">
					<font color=red>${message }</font>
					<font color=red>${messages}</font>
				</td>
			</tr>
			<tr>
				<td valign="top">
					<table width="100%" border="0" cellpadding="0" class="text">
						<tr>
							<td align="left">
								<form action="learnsUserAction.do" name="myform" method="post">
									<INPUT type="hidden" name="action" value="add" />
									<table align="center" width="700">
										<tr>
											<td width="100">
												<span class="text">用户名:</span>
											</td>
											<td width="300">
												<input type="text" name="nickname" value="${param.nickname}">
												<span class="asterisk">&nbsp;*</span> &nbsp;&nbsp;&nbsp;
												<input type="button" value="验证用户名" onclick="myValidator()">
											</td>
											<td align="left" width="300">
												<span class="asterisk" id="msg_prompt">${validatorMessage}</span>
											</td>
										</tr>
										<tr>
											<td>
												<span class="text">真实姓名</span>
											</td>
											<td>
												<input type="text" name="name" value="${param.name}">
											</td>
											<td></td>
										</tr>
										<tr>
											<td>
												<span class="text">口令</span>
											</td>
											<td>
												<input type="password" name="password" class="text">
												<span class="asterisk">&nbsp;*</span>
											</td>
											<td></td>
										</tr>
										<tr>
											<td>
												<span class="text">口令确认</span>
											</td>
											<td>
												<input type="password" name="password2" class="text">
												<span class="asterisk">&nbsp;*</span>
											</td>
											<td></td>
										</tr>
										<tr>
											<td>
												<span class="text">生日</span>
											</td>
											<td>
												<input type="text" name="birthday" value="${param.birthday}"
													onfocus="calendar()">
											</td>
											<td></td>
										</tr>
										<tr>
												<td>
													<span class="text">密码提示问题:</span>
												</td>
												<td>
													<select name="passQuestion">
													<option value="1">您的宠物的名字？</option>
													<option value="2">您就读的第一所学校的名称？</option>
													<option value="3">少年时代心目中的英雄是谁？</option>
													<option value="4">您最喜欢的休闲运动是什么？</option>
													<option value="5">您最喜欢的运动员是谁？</option>
													<option value="6">您的第一辆汽车或自行车是什么牌子的？</option>
													<option value="7">您最喜欢哪支运动队？</option>
												</select>
												</td>
												<td></td>
	
											</tr>
											<tr>
												<td>
													<span class="text">密码提示答案:</span>
												</td>
												<td>
													<input type="text" name="passQuestionAnswer"><span class="asterisk">&nbsp;*</span>
												</td>
												<td align="left"><span>2个字符以上</span></td>
											</tr>
										<tr>
											<td>
												<span class="text">性别</span>
											</td>
											<td>
												<select name="gender">
													<option value="1"
														<c:if test="${param.gender==1}">selected</c:if>>
														男
													</option>
													<option value="2"
														<c:if test="${param.gender==2}">selected</c:if>>
														女
													</option>
												</select>												
											</td>
											<td></td>
										</tr>
										<tr>
											<td>
												<span class="text">用户类型</span>
											</td>
											<td>
												<select name="userType">
													<option value="1"
														<c:if test="${param.userType==1}">selected</c:if>>
														学生
													</option>
													<option value="2"
														<c:if test="${param.userType==2}">selected</c:if>>
														家长
													</option>
													<option value="3"
														<c:if test="${param.userType==3}">selected</c:if>>
														过路人
													</option>
												</select>											
											</td>
											<td></td>
										</tr>
										<tr>
											<td>
												<span class="text">学历</span>
											</td>
											<td>
												<select name="degree">
													<option value="1">小学</option>
													<option value="2">初一</option>
													<option value="3">初二</option>
													<option value="4">初三</option>
													<option value="5">高一</option>
													<option value="6">高二</option>
													<option value="7">高三</option>
													<option value="8">大学</option>
													<option value="9">硕士</option>
													<option value="10">其它</option>
												</select>
												<script language="javascript">
												document.myform.degree.value = ${user.degree == null ? 5 : user.degree};
												</script>			
											</td>
											<td></td>
										</tr>
										<tr>
											<td>
												<span class="text">E_Mail</span>
											</td>
											<td>
												<input type="text" name="email" value="${param.email}">
												<span class="asterisk">&nbsp;*&nbsp;&nbsp;</span>
											</td>
											<td align="left">帐户激活邮件将发到这个电子邮箱</td>
										</tr>
										<tr>
											<td>
												<span class="text">电话</span>
											</td>
											<td>
												<input type="text" name="tel" value="${param.tel}">
												<span class="asterisk">&nbsp;*</span>
											</td>
											<td></td>
										</tr>
										<tr>
											<td>
												<span class="text">地址</span>
											</td>
											<td>
												<input type="text" name="address" value="${param.address}">
												<span class="asterisk">&nbsp;</span>
											</td>
											<td></td>
										</tr>
										<tr>
											<td>
												<span class="text">简单介绍:</span>
											</td>
											<td>
												<textarea rows="4" cols="40" name="myIntroduction">${param.myIntroduction}</textarea>
												<span class="asterisk"></span>
											</td>
											<td></td>
										</tr>
						
					                    <tr>
					                         <td><span class="bigText">验证码:</span></td>
					                         <td>                           
					                             <input type="text" name="number" size=8 maxlength="4">                           
					                             <jsp:include flush="true" page="rand.jsp?name=rand" />                         
					                         </td>
					                         <td></td>
					                    </tr>		
					                    								 
										<tr>
											<td></td>
											<td>
												<input type="button" onclick="validata('<%=session.getAttribute("rand")%>')" value="提交">
												&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
												<input type="reset" value="重填">
											</td>

											<td></td>
										</tr>
									</table>
								</form>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</TABLE>
		<div class="div_copyright">
			Copyright @ 2007
			<a href="http://www.2collegeboard.com" target="_blank"
				class="a_copyright">2collegeboard.com</a> all right reserved.
		</div>
	</body>
</html>
